entry、context
context:string,配置入口文件的路径
//webpack.config.js
var path = require('path');
module.exports = {
context:path.resolve(__dirname,"src"),
entry:"./js/index.js"
}
指定入口文件在当前目录下的src目录中。那么实际入口文件路径就是:"src/js/index.js"。
实践证明,htmlWebpackPlugin插件的template属性路径,也受context影响。
entry:string | array | object,入口文件
- 字符串 单文件入口,可以在该文件通过import导入其它文件,最终该文件会被输出一个文件。
数组
{ entry:['index.js','another.js'] }多文件入口,最终会按顺序压缩成一个文件输出。
对象
{ entry:{ index:'index.js', another:'another.js' } }多文件入口,以键值对的形式,最终会按顺序输出多个文件